package me.militch.quickcore.sample.host;

import android.app.Activity;

import java.util.List;

import javax.inject.Inject;

import me.militch.quickcore.event.ListViewEvent;
import me.militch.quickcore.event.ViewEvent;
import me.militch.quickcore.execute.ModelAndListView;
import me.militch.quickcore.execute.ModelAndView;
import me.militch.quickcore.mvp.model.ModelHelper;
import me.militch.quickcore.mvp.presenter.QuickPresenter;
import me.militch.quickcore.sample.bean.UserInfo;
import me.militch.quickcore.sample.service.MainService;
import me.militch.quickcore.util.ApiException;

public final class MainPresenter extends QuickPresenter implements MainContract.Presenter {
    @Inject
    MainPresenter(Activity activity, ModelHelper modelHelper) {
        super(activity, modelHelper);
    }

    @Override
    public void simpleRequest() {
        ModelAndView.create(view(MainContract.View.class),modelHelper()).request(service(MainService.class).requestTest(), new ViewEvent<MainContract.View, List<UserInfo>>() {
            @Override
            public void call(MainContract.View view, List<UserInfo> data) {
                view.bindData(data);
            }
        }, new ViewEvent<MainContract.View, ApiException>() {
            @Override
            public void call(MainContract.View view, ApiException data) {
                view.showToastMsg(data.getMessage());
            }
        });

//        ModelAndListView.create(view(MainContract.View.class),
//                modelHelper())
//                .request(service(MainService.class)
//                                .requestTest(),
//                        new ListViewEvent<UserInfo>());

    }

}
